/*
 * Copyright (c) 2012-2013, Qualcomm Technologies, Inc.
 * All Rights Reserved.
 * Qualcomm Technologies Proprietary and Confidential.
 */

package com.android.hw.projectmenu;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.PowerManager;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.util.Log;

public class PlmnCheck extends PreferenceActivity implements OnPreferenceClickListener {
	
	private static final String KEY_PLMN_ID = "plmn_id";
	private static final String KEY_PLMN_NS = "plmn_ns";
	private static final String KEY_PLMN_SP = "plmn_sp";
	private Context mContext = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		mContext = this;
		addPreferencesFromResource(R.xml.plmn_check);
		PreferenceScreen plmnIdPS= (PreferenceScreen) findPreference(KEY_PLMN_ID);
		plmnIdPS.setOnPreferenceClickListener(this);
		PreferenceScreen plmnNsPS= (PreferenceScreen) findPreference(KEY_PLMN_NS);
		plmnNsPS.setOnPreferenceClickListener(this);
		PreferenceScreen plmnSpPS= (PreferenceScreen) findPreference(KEY_PLMN_SP);
		plmnSpPS.setOnPreferenceClickListener(this);
	}

	@Override
	public boolean onPreferenceClick(Preference preference) {
		// TODO Auto-generated method stub
		String key = preference.getKey();
		if (KEY_PLMN_ID.equals(key)) {
			showDialog(getString(R.string.plmn_id), "0:46003\n1:46011\n2:45502");
		} else if (KEY_PLMN_NS.equals(key)) {
			showDialog(getString(R.string.plmn_ns), "unSupport");
		} else if (KEY_PLMN_SP.equals(key)) {
			showDialog(getString(R.string.plmn_sp), "unSupport");
		}
		return false;
	}
	
	private void showDialog(String title, String msg) {
		AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
		builder.setTitle(title)
			   .setMessage(msg)
		       .setCancelable(false)
		       .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
		           public void onClick(DialogInterface dialog, int id) {
		        	   
		           }
		       });
		AlertDialog alert = builder.create();
		alert.show();
	}
		       
}
